/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package com.crmapi.service.impl;

import com.crmapi.mapper.CustomerMapper;
import com.crmapi.pojo.Customer;
import com.crmapi.pojo.PageBean;
import com.crmapi.pojo.Receive;
import com.crmapi.service.CustomerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>Project: CRMSystem - CustomerServiceImpl</p>
 * <p>Powered by yzc On 2023-11-23 09:16:40</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    CustomerMapper customerMapper;
    //分页条件查询
    @Override
    public PageBean queryList(Integer page, Integer pageSize, String name, Integer source, Integer level, Integer followStatus,Integer status) {
        PageHelper.startPage(page,pageSize);
        List<Customer> list =customerMapper.queryList(name, source, level, followStatus,status);
        PageInfo pageInfo = new PageInfo<>(list);
        PageBean pageBean = new PageBean(pageInfo.getTotal(),list);
        return pageBean;
    }


    //添加客户
    @Override
    public int insertCustomer(Customer customer) {

        return customerMapper.insertCustomer(customer);
    }

    //批量删除
    @Override
    public int del(List<String> ids) {
        return customerMapper.del(ids);
    }


    //更新客户
    @Override
    public int updateCustomer(Customer customer) {
        return customerMapper.updateCustomer(customer);
    }

    //领取客户
    @Override
    public int receive(Receive receive) {
        return customerMapper.receive(receive);
    }


    //放回公海
    @Override
    public int radiance(List<String> ids) {
        return customerMapper.radiance(ids);
    }

    //查询全部客户
    @Override
    public List<Customer> queryAll() {
        return customerMapper.queryAll();
    }
    //根据id差联系人
    @Override
    public String queryContact(String id) {
        return customerMapper.queryContact(id);
    }
}
